package com.UdpRecieve.framework.config;

import com.UdpRecieve.framework.interceptor.LoginInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.util.Arrays;
import java.util.List;

@Configuration
public class WebAppConfiguration implements WebMvcConfigurer {

    private static final List<String> EXCLUDE_PATH
            = Arrays.asList("/","/login","/doLogin","/error","/css/**","/js/**","/img/**","/libs/**","/258Service");

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //注册通用拦截器
        registry.addInterceptor(new LoginInterceptor())
                .addPathPatterns("/**")
                .excludePathPatterns(EXCLUDE_PATH);
        //注册错误界面拦截器
        /*registry.addInterceptor(new ErroInterceptor())
                .addPathPatterns("/error");*/
    }


}
